<?php

error_reporting(E_ALL);

/**
 * ECommerce - class.ModeloUsuario.php
 *
 * $Id$
 *
 * This file is part of ECommerce.
 *
 * Automatically generated on 17.11.2011, 17:43:22 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/* user defined includes */
// section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CC7-includes begin
require_once('class.Conexion.php');
// section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CC7-includes end

/* user defined constants */
// section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CC7-constants begin
// section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CC7-constants end

/**
 * Short description of class ModeloUsuario
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloUsuario
Extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method getAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function getAllRows()
    {
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CC8 begin
        $sql = "SELECT * FROM usuarios";
		return $this->ejecutarQuery($sql);
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CC8 end
    }

    /**
     * Short description of method searchById
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return void
     */
    public function searchById($id)
    {
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CCA begin
        $sql = "SELECT * FROM usuarios WHERE idusuario = '$id'";
		$row0 = $this->ejecutarQuery($sql);
		return $row0[0];
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CCA end
    }

    /**
     * Short description of method insertRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return void
     */
    public function insertRow($datos)
    {
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CCC begin
        $nombre = @$datos['nombre'];
        $password = @$datos['password'];
		$telefono = @$datos['telefono'];
		$email = @$datos['email'];
		$rol = @$datos['rol'];
		$sql = "INSERT INTO usuarios (nombre,password,telefono,email,rol) VALUES ('$nombre','$password',$telefono,'$email','$rol')";
		$this->ejecutarQuery($sql);	
		return mysql_insert_id();
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CCC end
    }

    /**
     * Short description of method updateRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return void
     */
    public function updateRow($datos)
    {
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CD6 begin
        		$sql= "
			    UPDATE usuarios SET 
				Nombre = '".@$datos[nombre]."',
				Nombre = '".@$datos[password]."',
				Telefono = '".@$datos[telefono]."',
				Email = '".@$datos[email]."',
				Rol = '".@$datos[rol]."'
				WHERE idusuario = '".@$datos['idusuario']."'
		";
		$this->ejecutarQuery($sql);
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CD6 end
    }

    /**
     * Short description of method deleteRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return void
     */
    public function deleteRow($id)
    {
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CD9 begin
        $sql= "DELETE FROM usuarios WHERE idusuario = $id";
		$this->ejecutarQuery($sql);
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CD9 end
    }

    /**
     * Short description of method getRowsByNombre
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  nombre
     * @return void
     */
    public function getRowsByNombre($nombre)
    {
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CDC begin
        $sql = "SELECT * FROM usuarios WHERE nombre LIKE '%".$nombre."%'";
		return $this->ejecutarQuery($sql);
        // section -84-27-7--68-30076843:133b28e8ad6:-8000:0000000000000CDC end
    }

    /**
     * Short description of method getRowsByUserPassword
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  user
     * @param  pass
     * @return void
     */
    public function getRowsByUserPassword($user, $pass)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001D02 begin
        $sql = "SELECT * FROM usuarios WHERE 
       		Nombre = '".$user."' 
       		AND Password = '".$pass."'";
       $row = $this->ejecutarQuery($sql);
		return $row[0];
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001D02 end
    }

} /* end of class ModeloUsuario */

?>